import java.util.Arrays;

public class Solution1 {
    public long minimumTime(int[] time, int totalTrips) {
        //二分，左面的性质是趟数不够，右面是趟数够了
        //经过分析，我们要大于等于的情况
        Arrays.sort(time);
        long left=0;
        long right=100010;

        while(left<right){
            long mid=left+(right-left)/2;
            if(check(time,mid,totalTrips)){
                right=mid;
            }else{
                left=mid+1;
            }
        }
        return right;
    }
    public boolean check(int[] time,long num,long total){
        for (int i = 0; i < time.length; i++) {
            long t=num/time[i];
            total-=t;
            if(total<=0){
                return true;
            }
        }
        return false;
    }
}
